/* Define to prevent recursive inclusion -------------------------------------*/
#ifndef __USART_H
#define __USART_H

#ifdef __cplusplus
 extern "C" {
#endif

/* Includes ------------------------------------------------------------------*/
#include "stm32f10x_gpio.h"
#include "stm32f10x_rcc.h"
#include "stm32f10x_usart.h"
#include "typedef.h"
#include <stdio.h>

typedef enum usartxType_t
{
    USART1_T = 1,
    USART2_T,
    USART3_T,
    MAX_USART_T
}usartxTyp;

typedef struct usartxPinInfo_t
{
    GPIO_TypeDef* GPIOx;
    uint16        Tx_Pin;
    uint16        Rx_Pin;
    uint32        gpioClock;
}usartxPinInfo;

typedef struct usartxInfo_t
{
    usartxPinInfo* usartxPin;
    USART_TypeDef* USARTx;
    usartxTyp      usartType;
    uint32         usartClock;
    uint32         baud;
}usartxInfo;

extern usartxPinInfo usartPin;
extern usartxPinInfo usart2Pin;
extern usartxInfo usartInfo;
extern usartxInfo usart2Info;

extern void usartInit(usartxInfo *usartInfo);
extern void uartx_sendByte(usartxInfo *uart, uint8 data);
extern uint8 uartx_recvByte(usartxInfo *uart);
extern void uartx_sendString(usartxInfo *uart, const int8 *str);
extern void uart1_sendByte(u8 data);
#ifdef __cplusplus
}
#endif
#endif /* __USART_H */
